SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Agurto, Jorge>
-- Create date: <29/10/2011>
-- Description:	<Hace todas las modificaciones necesarias al realizar una carga>
-- =============================================
CREATE PROCEDURE [GOOGLECODERS].RegistrarCarga 
	@IdTarjeta int,
	@Monto float,
	@Fecha datetime 
AS
BEGIN
	BEGIN TRAN registrarCarga
	BEGIN TRY
		SET NOCOUNT ON;

		INSERT INTO [GOOGLECODERS].[Cargas]
		VALUES(@IdTarjeta, @Fecha, @Monto)
		
		UPDATE [GOOGLECODERS].[Tarjetas]
		SET Credito = ([GOOGLECODERS].CreditoTarjeta(@IdTarjeta) + @Monto)
		WHERE IdTarjeta = @IdTarjeta

		COMMIT TRAN registrarCarga
		RETURN
	END TRY
	BEGIN CATCH
		ROLLBACK TRAN registrarCarga
		RETURN
	END CATCH
END
GO